package com.sb.shiro.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.sb.shiro.entity.User;
import com.sb.shiro.service.IUserService;

/**
 * 
 * 代码生成器，参考源码测试用例：
 * 
 * /mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java
 *
 */
@RestController
@RequestMapping("/user")
public class UserController {

	@Autowired
	private IUserService userService;

	/**
	 * 分页 PAGE
	 */
	@GetMapping("/test")
	public Page<User> test() {
		return userService.selectPage(new Page<User>(0, 12));
	}

	
	/**
	 * 插入 OR 修改
	 */
	@GetMapping("/test3")
	public User test3() {
		userService.insertOrUpdate(new User());
		return userService.selectById(1L);
	}

	@GetMapping("/add")
	public Object addUser(){
		User user = new User();
		user.setName("test");
		JSONObject result = new JSONObject();
		Boolean tt = userService.insert(user);
		result.put("result",tt);
		return result;
	}
	


}
